using MediatR;
using SumerCoreDevOps.Application.NodeLogs.Queries;
using SumerCoreDevOps.Domain.Entities;
using SumerCoreDevOps.Infrastructure.Logging;

namespace SumerCoreDevOps.Application.NodeLogs.Handlers;

public class GetLogsByPipelineInstanceIdQueryHandler : IRequestHandler<GetLogsByPipelineInstanceIdQuery, List<NodeOperationLog>>
{
    private readonly NodeOperationLogManager _logManager;

    public GetLogsByPipelineInstanceIdQueryHandler(NodeOperationLogManager logManager)
    {
        _logManager = logManager;
    }

    public async Task<List<NodeOperationLog>> Handle(GetLogsByPipelineInstanceIdQuery request, CancellationToken cancellationToken)
    {
        return await _logManager.GetLogsByPipelineInstanceIdAsync(request.PipelineInstanceId);
    }
}
